package com.cet.designapplication.bridge.function;

import com.cet.designapplication.bridge.abst.factory.RegisterLoginComponentFactory;
import com.cet.designapplication.pojo.UserInfo;
import com.cet.designapplication.repo.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author NSOC
 */
@Component
public class RegisterLoginByDefault extends AbstractRegisterLoginFunc{

    @Autowired
    private UserRepository userRepository;

    @PostConstruct
    public void initFunMap() {
        RegisterLoginComponentFactory.FUNC_MAP.put("DEFAULT", this);
    }

    @Override
    public String login(String account, String password) {
        return super.commonLogin(account, password, userRepository);
    }

    @Override
    public String register(UserInfo userInfo) {
        return super.commonRegister(userInfo, userRepository);
    }

    @Override
    public boolean checkUserExists(String userName) {
        return super.commonCheckUserExists(userName, userRepository);
    }
}
